const mongoose = require('mongoose');
const config = require('./config');
mongoose.Promise = global.Promise;

module.exports = function () {
    mongoose.connect(config.db, {useMongoClient: true});
    var db = mongoose.connection;
    db.on('error', console.error.bind(console, 'connection error!'));
    db.once('open', function() {
        console.log('opened db!');
    });
    require('../models/user.server.model');
    require('../models/article.server.model');
    require('../models/relationship.server.model');
    return db;
};